package com.fw.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import javax.validation.Valid;
import static com.fw.mes.ResultUtils.success;
import com.fw.system.admin.domain.TbNotice;
import com.fw.system.admin.service.ITbNoticeService;
import com.fw.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import com.fw.core.page.TableDataInfo;

/**
 * 公告、炸弹护盾使用情况Controller
 * 
 * @author yanwei
 * @date 2023-04-04
 */
@Api(tags = "notice")
@RestController
@RequestMapping("/admin/notice")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class TbNoticeController extends BaseController
{
    @Autowired
    private ITbNoticeService tbNoticeService;

    /**
     * 查询公告、炸弹护盾使用情况列表
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:list')")
    @GetMapping("/list")
    @ApiOperation("查询公告、炸弹护盾使用情况列表")
    public TableDataInfo list(TbNotice tbNotice)
    {
        startPage();
        List<TbNotice> list = tbNoticeService.selectTbNoticeList(tbNotice);
        return getDataTable(list);
    }

    /**
     * 导出公告、炸弹护盾使用情况列表
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:export')")
    @Log(title = "公告、炸弹护盾使用情况", businessType = BusinessType.EXPORT)
    @ApiOperation("导出公告、炸弹护盾使用情况列表")
    @GetMapping("/export")
    public AjaxResult export(TbNotice tbNotice)
    {
        List<TbNotice> list = tbNoticeService.selectTbNoticeList(tbNotice);
        ExcelUtil<TbNotice> util = new ExcelUtil<TbNotice>(TbNotice.class);
        return util.exportExcel(list, "notice");
    }

    /**
     * 获取公告、炸弹护盾使用情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取公告、炸弹护盾使用情况详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbNoticeService.selectTbNoticeById(id));
    }

    /**
     * 新增公告、炸弹护盾使用情况
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:add')")
    @Log(title = "公告、炸弹护盾使用情况", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增公告、炸弹护盾使用情况")
    public AjaxResult add(@RequestBody TbNotice tbNotice)
    {
        return toAjax(tbNoticeService.insertTbNotice(tbNotice));
    }

    /**
     * 修改公告、炸弹护盾使用情况
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:edit')")
    @Log(title = "公告、炸弹护盾使用情况", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改公告、炸弹护盾使用情况")
    public AjaxResult edit(@RequestBody TbNotice tbNotice)
    {
        return toAjax(tbNoticeService.updateTbNotice(tbNotice));
    }

    /**
     * 删除公告、炸弹护盾使用情况
     */
    @PreAuthorize("@ss.hasPermi('admin:notice:remove')")
    @Log(title = "公告、炸弹护盾使用情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除公告、炸弹护盾使用情况")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbNoticeService.deleteTbNoticeByIds(ids));
    }
}
